<?php

namespace app\admin\validate;

use think\Validate;

class Merchant extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'merchant_name' => 'require|unique:merchant',
        'abbr' => 'require|unique:merchant',
        'merchant_tel' => 'require|unique:merchant',
        'address'    => 'require',
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'merchant_name.unique' => "企业名称不能重复",
        'abbr.unique' => "企业简称不能重复",
        'merchant_tel.unique' => "企业联系电话不能重复",
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['merchant_name', 'abbr', 'merchant_tel', 'address'],
        'edit' => ['merchant_name', 'abbr', 'merchant_tel', 'address'],
    ];
    
    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'merchant_name' => "企业名称",
            'abbr' => "企业简称",
            'merchant_tel'   => "联系电话",
            'address'   => "企业地址",
        ];
        parent::__construct($rules, $message, $field);
    }
}
